//引入vue库
import Vue from 'vue'
import Vuex from 'vuex'

//图片预览组件（多图）
// import vuePicturePreview from 'vue-picture-preview-extend'
// Vue.use(vuePicturePreview)

//图片预览组件（单图，带手势放大）
import gallery from 'img-vuer'
Vue.use(gallery)

//引入动画库组件
import 'animate.css'

//引入裁切
import VueCropper from 'vue-cropper'

//引入裁切组件
import CropperImage from './components/cropperImage'

//引入图片上传组件
import UploadImage from './components/uploadImage'


import 'mint-ui/lib/style.css'
import { 
  Loadmore,
  Popup,
  DatetimePicker,
  Picker,
  Actionsheet,
  Switch
} from 'mint-ui'

//mint-UI按需引入组件
Vue.component(Loadmore.name, Loadmore);
Vue.component(Popup.name, Popup);
Vue.component(DatetimePicker.name, DatetimePicker);
Vue.component(Picker.name, Picker);
Vue.component(Actionsheet.name, Actionsheet);
Vue.component(Switch.name, Switch);

//使用组件
Vue.use(VueRouter)
Vue.use(Vuex)
Vue.use(UploadImage)
Vue.use(VueCropper)
Vue.use(CropperImage)

import VueLazyload from 'vue-lazyload'
Vue.use(VueLazyload, {
  error   : './static/images/morentu.jpg',
  loading : './static/images/morentu.jpeg'
})

//引入入口模板文件
import App from './app.vue' 

//引入路由库
import VueRouter from 'vue-router'

//引入全局常量配置
import Global from './config/global'
Vue.prototype.$global = Global

//引入网络操作库
import Network from './common/network'
Vue.prototype.$http = Network

//引入本地用户数据对象
import UserData from './localData/userData'
Vue.prototype.$userData = UserData

//引入本地数据操作对象
import LocalData from './common/localData'
Vue.prototype.$localData = LocalData

//引入JS工具集
// import * as _ from 'lodash';
// Vue.prototype.$_ = _

//引入API接口配置文件
import Api from './api/api'
Vue.prototype.$API = Api


//引入路由配置
import createRouter from './config/router'
import createStore from './store/store'

//引入Velocity动画
// import '../node_modules/velocity-animate/velocity.min'


//引入公共方法文件
import Common from './common/common'
Vue.prototype.$common = Common

//引入简单操作库
import EasyUtil from './common/easyUtil'
Vue.prototype.$easyUtil = EasyUtil

//保存当前环境
Vue.prototype.$isDev = process.env.NODE_ENV === 'development'

//初始化相关对象
const store  = createStore()
const router = createRouter(store)

//引入公共CSS文件库
import './assets/style/global.styl'
import './assets/font/font-awesome/css/font-awesome.min.css'


import otherConfig from './config/otherConfig'

//引入额外文件处理
var otherFile = otherConfig.otherFile;

var head = document.head || document.getElementsByTagName('head')[0];
for(var i =0;i<otherFile.length;i++){
  if(otherFile[i].type == 'css'){
    var style = document.createElement('style');
    style.setAttribute("href", otherFile[i].url);
    style.setAttribute("rel",  "stylesheet");
    style.setAttribute("type", "text/css");
    head.appendChild(style);
  }

  if(otherFile[i].type == 'js'){
    var script = document.createElement('script');
    script.setAttribute("src", otherFile[i].url);
    head.appendChild(script);
  }
}


new Vue({
  router,
  store,
  render : (h) => h(App),
  mounted(){

  },
  components: {
    'remote-js': {
     render(createElement) {
     return createElement('script', { attrs: { type: 'text/javascript', src: this.src }});
    },
    props: {
     src: { type: String, required: true },
    },
   },
   },
}).$mount('#root')



